/**	
 * DroidKit is a toolkit for the Android platform
 * Copyright (C) 2012  Jonathan Bonazza
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */

package com.droidkit.net;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Proxy;
import java.net.Socket;
import java.net.UnknownHostException;

public abstract class AbstractSocketClient 
{
	protected String uid;
	protected Socket soc;
	protected String address;
	protected int port;
	
	public AbstractSocketClient(String uid, String addr, int port) throws IOException, UnknownHostException
	{
		this.uid = uid;
		this.address = addr;
		this.port = port;
		
		soc = new Socket(addr,port);
	}
	
	public AbstractSocketClient(String uid, Proxy proxy)
	{
		this.uid = uid;
		soc = new Socket(proxy);
	}
	
	public AbstractSocketClient(String uid, String addr, int port, InetAddress localAddr, int localPort) throws IOException, UnknownHostException
	{
		this.uid = uid;
		soc = new Socket(addr, port, localAddr, localPort);
	}
	
	public AbstractSocketClient(String uid, InetAddress addr, int port) throws IOException
	{
		this.uid = uid;
		soc = new Socket(addr, port);
	}
	
	public AbstractSocketClient(String uid, InetAddress addr, int port, InetAddress localAddr, int localPort) throws IOException
	{
		this.uid = uid;
		
		soc = new Socket(addr, port, localAddr, localPort);
	}
	
	
	public abstract void sendMessage(String msg) throws IOException;
	public abstract String recieveMessage() throws IOException;
	
	public String getUID()
	{
		return uid;
	}
	
	public String getAddress()
	{
		return address;
	}
	
	public int getPort()
	{
		return port;
	}
	
	public String toString()
	{
		return "UID: " + uid + 
				"\nAddress: " + address +
				"\nPort: " + port;
	}
}
